Chore/update prefixes#219
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the message prefix system in surf-api-core-api by centralizing prefix construction in Colors and introducing type-specific async helpers for prefix + newline composition, while deprecating the generic “prefixed line” helpers on SurfComponentBuilder.
Changes:
- Refactors
Colorsto generatePREFIX/INFO_PREFIX/SUCCESS_PREFIX/WARNING_PREFIX/ERROR_PREFIXvia a sharedbuildPrefix(...)helper. - Adds
appendNew{Type}PrefixedLineAsync(...)helpers to the Info/Success/Warning/Error component builder color interfaces. - Deprecates
SurfComponentBuilder.appendNewPrefixedLine(...)andappendNewPrefixedLineAsync(...)in favor of type-specific helpers.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
.../builder/colors/WarningComponentBuilderColor.kt |
Adds async helper to append newline + warning prefix and then append async block. |
.../builder/colors/SuccessComponentBuilderColor.kt |
Adds async helper to append newline + success prefix and then append async block. |
.../builder/colors/InfoComponentBuilderColor.kt |
Adds async helper to append newline + info prefix and then append async block. |
.../builder/colors/ErrorComponentBuilderColor.kt |
Adds async helper to append newline + error prefix and then append async block. |
.../builder/SurfComponentBuilder.kt |
Deprecates generic prefixed-line helpers to steer callers toward type-specific APIs. |
.../messages/Colors.kt |
Centralizes prefix rendering with PREFIX_CHARACTER + ` |
| @Deprecated("Use TYPE specific functions") | ||
| fun appendNewPrefixedLine(block: SurfComponentBuilder.() -> Unit) = | ||
| appendNewPrefixedLine().append(block) |
There was a problem hiding this comment.
The @deprecated message "Use TYPE specific functions" is unclear to API consumers (what is "TYPE" and which functions should they migrate to?). Consider making the message explicit (e.g., refer to appendNewInfoPrefixedLine/appendNewSuccessPrefixedLine/etc.) so the deprecation warning is actionable.
| @Deprecated("Use TYPE specific functions") | ||
| suspend fun appendNewPrefixedLineAsync(block: suspend SurfComponentBuilder.() -> Unit) = | ||
| appendNewPrefixedLine().appendAsync(block) |
There was a problem hiding this comment.
Same as above: the deprecation message is not actionable. If appendNewPrefixedLineAsync is being replaced by type-specific async helpers, the message should point to the concrete replacements to avoid confusing downstream plugin authors.
| /** | ||
| * The default prefix color (#3b92d1). | ||
| * Applied to all prefixes for consistency across Surf plugins. | ||
| */ | ||
| @JvmField | ||
| val PREFIX_COLOR: TextColor = PRIMARY | ||
|
|
There was a problem hiding this comment.
KDoc for PREFIX_COLOR says it is "applied to all prefixes", but INFO_PREFIX/SUCCESS_PREFIX/WARNING_PREFIX/ERROR_PREFIX now call buildPrefix(INFO/SUCCESS/WARNING/ERROR) instead of PREFIX_COLOR. Either update the KDoc to reflect the per-type coloring, or pass PREFIX_COLOR to buildPrefix for all prefixes if the intent is consistency.
No description provided.